package net.esj.basic.dao.hibernate;

import java.io.Serializable;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.orm.hibernate4.SessionFactoryUtils;
import org.springframework.stereotype.Service;

public class Hibernate3SessionLocale extends HibernateTemplate implements HibernateSessionLocale{

	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		super.setSessionFactory(sessionFactory);
	}
	
	public Session getCurrentSession(){
		try{
			return getSession();
		}catch(HibernateException e){
			return SessionFactoryUtils.openSession(getSessionFactory());
		}
	}

	@Override
	public <T> T get(Serializable id, Class<T> clazz) {
		return super.get(clazz, id);
	}
	
	public <T> T load(Serializable id, Class<T> clazz) {
		return super.load(clazz, id);
	}
	
	
}
